package com.zdp.demo.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@AllArgsConstructor
@NoArgsConstructor
@Builder
@Data
public class PageResult<T> {

    private Long totalSize;

    private Long current;

    private Long size;

    private List<T> result;

    public static <T> PageResult<T> convert(Page<T> page) {
        return (PageResult<T>) PageResult.builder().totalSize(page.getTotal()).current(page.getCurrent()).size(page.getSize()).result((List<Object>) page.getRecords()).build();
    }

}
